<?php


namespace App\Controller\Backend;


use App\Library\Controller\MyController;
use App\Library\Helper\GeneralHelper;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Symfony\Component\HttpFoundation\Request;

class PathsAdminController extends MyController
{

    protected function preEdit(Request $request, $object)
    {
        return $this->verify($object);
    }

    protected function preShow(Request $request, $object)
    {
        return $this->verify($object);
    }

    protected function preDelete(Request $request, $object)
    {
        return $this->verify($object);
    }

    public function batchActionDelete(ProxyQueryInterface $query)
    {
        $result = parent::batchActionDelete($query); // TODO: Change the autogenerated stub

        // 是否自动更新文档
        GeneralHelper::getOneInstance()->buildCurrentInfoApiConfig();

        return $result;
    }

    /**
     * User: Gao
     * Date: 2020/1/13
     * Description: 导入postman
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function importAction(Request $request)
    {
        $fields = $this->admin->getShow();
        return $this->renderWithExtraParams('Backend/paths/import.html.twig', [
            'action' => 'import',
            'elements' => $fields,
        ]);
    }
}